package main

import (
	"flag"
	"log"
	"os"
	"os/signal"
	"time"
	"wxp2p/client"
	"wxp2p/common"
)

var helper_server_addr1 = flag.String("addr", "43.138.80.3:8018", "http service address")

// var helper_server_addr1 = flag.String("addr", "127.0.0.1:8018", "信号服务地址")
var clientclientId = flag.String("id", "wangxue", "客户端标识符")
var local_port1 = flag.String("port", "2222", "本地端口")

func main() {
	flag.Parse()
	log.Println("客户端模式")
	interrupt := make(chan os.Signal, 1)
	signal.Notify(interrupt, os.Interrupt)
	client.G_ClientType = common.EClientClient
	go client.BeginLinkClient(*clientclientId)
	// go client.RunWebrtcOffer(*clientclientId)
	go client.ClientLocalRecvChanHandler()
	go client.ListenLocalTCP(*local_port1)
	go client.LinkSignalServer(*helper_server_addr1, *clientclientId)
	<-interrupt
	log.Println("user interrupt,waitting for 1 secend")
	<-time.After(time.Second)
}
